$(function(){

    $('#login').click(function(){
        var loginName=$("#loginName").val();
        var password=$("#password").val();
        if(loginName==""){
            $("#msg").html("请输入用户名");
        }else if(password==""){
            $("#msg").html("请输入密码");
        }else{
            $.ajax({
            url:"/easybuyUser/searchUser",
            data:{
                "loginName":loginName,
                "password":password
            },
            success:function (data) {
                if(data==""){
                    $("#msg").html("用户名或密码不正确");
                }else{
                    $.ajax({
                        url:"/easybuyUser/dologin",
                        data:{
                            "loginName":loginName,
                            "password":password
                        },
                        success:function(data){
                            alert(data);
                            localStorage.setItem('obj',data);
                            location.href="index.html";
                        }
                    })
                }
            }
        })}

    })

})